class Gun:
    def __init__(self,model):
        self.model = model
        self.bullet = 0
    
    def add_bullet(self,count):
        self.bullet += count
    def shoot(self):
        if self.bullet <= 0:
            print("子弹还有%s,没有子弹le"%self.bullet)
            return
        self.bullet -= 1
        print("tututut---子注心弹还有%s"%self.bullet)

ak47 = Gun("AK47")
# ak47.add_bullet(3)
# ak47.shoot()
# ak47.shoot()
class Soldier:
    def __init__(self,name):
        self.name = name
        self.gun = None

    def fire(self):
        if self.gun == None:
            print("%s没有枪"%self.name)
            return
        self.gun.add_bullet(50)
        self.gun.shoot()




xushanduo = Soldier("许三多")
xushanduo.gun =ak47
xushanduo.fire()

# print(xushanduo.gun)
        
